home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* List msg command *)
- (* L -- List messages newer than last L command *)
- (* L0 -- Same as "L" but no pausing *)
- (* L n -- List messages with number >= n *)
- (* L_ -- List messages of type ' ' *)
- (* LA -- List messages of type 'A' *)
- (* LB -- List messages of type 'B' *)
- (* LD > d -- List messages newer than date d. *)
- (* LD < d -- List messages older than date d. *)
- (* LF n -- List forwarded messages greater than n *)
- (* LH n -- List held messages greater than n *)
- (* LK n -- List killed messages greater than n *)
- (* LL n -- List last n messages *)
- (* LM u -- List messages of a specific user. Default is current user *)
- (* LN n -- List messages just sitting here unread greater than n *)
- (* LO n -- List messages of with "old" attribute & number greater n *)
- (* LP -- List messages of type 'P' *)
- (* LR u -- List messages awaiting review *)
- (* LS s -- List messages with string in subject *)
- (* LT -- List NTS messages *)
- (* LU u -- List unread messages to user u. Current user is default *)
- (* LY n -- List all read messages greater than n *)
- (* L< u -- List messages from a user u. *)
- (* L> u -- List messages to a user u. *)
- (* L@ b -- List messages a mailbox b. *)
- (* L$ s -- List messages with string in the BID *)
- (* L+ n -- List messages in forwarding progress with number grtr n *)
- (* *)
- (* Copyright 1988, 1989, 1990, 1992 by H. Roy Engehausen. All rights *)
- (* reserved. *)
- (* *)
- (*===========================================================================*)
-
- {$O+}
-
- {$UNDEF DEBUG_L0}
-
- UNIT BBLMC;
-
- INTERFACE
-
- USES
- bbdummy,
- bbmdata,
- bbmess,
- bbmisc,
- bbmisc2,
- bbmf,
- bbmore,
- bbrdata,
- bbsdata,
- bbsearch,
- bbstr,
- bbtime;
-
- PROCEDURE list_msg_cmd(cmd_string : STRING);
-
- IMPLEMENTATION
-
- PROCEDURE list_msg_cmd(cmd_string : STRING);
- VAR
- code : INTEGER;
- command_l : BYTE; (* 0 = not "L", 1 = "L0", 2= "L" *)
- l_msg_no : LONGINT;
- save_l : LONGINT;
- search_block : search_block_type;
- word_count : BYTE;
-
- BEGIN;
-
- save_l := 0;
-
- (*-----------------------------------------------------------------------*)
- (* Parse command and execute right routine *)
- (*-----------------------------------------------------------------------*)
-
- word_count := WORDS(cmd_string);
-
- IF cmd_string <> 'L0' THEN
- command_l := 0
- ELSE
- BEGIN;
- command_l := 1;
- cmd_string := 'L';
- END;
-
- IF (LENGTH(cmd_string) <> 1) AND (cmd_string[2] <> ' ') THEN
- BEGIN;
- cmd_string := COPY(cmd_string, 2, 255);
- set_search(cmd_string, @search_block);
- IF active_tcb^.error_sw THEN
- EXIT;
- END
- ELSE
- BEGIN;
-
- (*-------------------------------------------------------------------*)
- (* Too many words *)
- (*-------------------------------------------------------------------*)
-
- IF word_count > 2 THEN
- BEGIN;
- send_message(message_err_wrd);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- (*--------------------------------------------------------------*)
- (* Init search block *)
- (*--------------------------------------------------------------*)
-
- FILLCHAR(search_block, SIZEOF(search_block), #0);
- search_block.search_nok := TRUE;
- search_block.search_above := TRUE;
-
- (*--------------------------------------------------------------*)
- (* Handle command operands *)
- (*--------------------------------------------------------------*)
-
- IF word_count > 1 THEN
- BEGIN;
-
- (*---------------------------------------------------------*)
- (* Operand present. This is a message number *)
- (*---------------------------------------------------------*)
-
- VAL(subword(@cmd_string, 2, 1), l_msg_no, code);
-
- IF (code <> 0) OR (l_msg_no > 65535) OR (l_msg_no < 1) THEN
- BEGIN;
- send_message(message_err_ivm);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- search_block.search_msg_no := l_msg_no;
- search_block.search_type := ' ';
-
- END
- ELSE
- BEGIN;
-
- (*---------------------------------------------------------*)
- (* No operand. Search for messages later than last *)
- (* time we looked. *)
- (*---------------------------------------------------------*)
-
- IF (command_l = 0) AND (opt_block.max_l_shown > 0) THEN
- command_l := 2;
-
- save_l := current_day_time;
- search_block.search_dt := active_tcb^.uid_data.user_l_time;
- search_block.search_type := 'D';
-
- END;
-
- END; (*----- End of 'L ' command handler ------------------------------*)
-
- (*-----------------------------------------------------------------------*)
- (* Execute the search *)
- (*-----------------------------------------------------------------------*)
-
- search_msg(@search_block);
-
- (*-----------------------------------------------------------------------*)
- (* If nothing found, tell user and exit *)
- (*-----------------------------------------------------------------------*)
-
- IF search_block.search_last = NIL THEN
- BEGIN;
- send_message(message_lmc_nf);
- EXIT;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* "L" command limiter *)
- (*-----------------------------------------------------------------------*)
-
- IF command_l = 2 THEN
- BEGIN;
- IF (active_tcb^.uid_data.user_scr_len < opt_block.max_l_shown)
- AND (active_tcb^.uid_data.user_scr_len <> 0) THEN
- command_l := 1
- ELSE
- BEGIN;
-
- (*---------------------------------------------------------------*)
- (* Count the messages *)
- (*---------------------------------------------------------------*)
-
- code := 0;
-
- REPEAT
- INC(code);
- search_msg(@search_block);
- UNTIL search_block.search_last = NIL;
-
- (*---------------------------------------------------------------*)
- (* If too many, handle it *)
- (*---------------------------------------------------------------*)
-
- IF code > opt_block.max_l_shown THEN
- BEGIN;
-
- (*-----------------------------------------------------------*)
- (* Send message *)
- (*-----------------------------------------------------------*)
-
- STR(code, cmd_string);
- set_dollar1_parm(@cmd_string);
-
- send_message(message_l_pause);
-
- (*-----------------------------------------------------------*)
- (* Get response *)
- (*-----------------------------------------------------------*)
-
- cmd_string := read_tnc_data_str;
-
- strip_crlf(cmd_string);
-
- (*-----------------------------------------------------------*)
- (* If nothing send back, quit *)
- (*-----------------------------------------------------------*)
-
- IF LENGTH(cmd_string) = 0 THEN
- BEGIN;
- send_message(message_nodata_can);
- EXIT;
- END;
-
- (*-----------------------------------------------------------*)
- (* If improper then quit *)
- (*-----------------------------------------------------------*)
-
- IF LENGTH(cmd_string) > 253 THEN
- BEGIN;
- send_message(message_err_wrd);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- VAL(cmd_string, l_msg_no, code);
-
- IF (code <> 0) OR (l_msg_no < 0) OR (l_msg_no > 32000) THEN
- BEGIN;
- send_message(message_bad_number);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- IF l_msg_no = 0 THEN
- command_l := 1
- ELSE
- active_tcb^.out_force := TRUE;
-
- {$IFDEF DEBUG_L0}
- WRITELN('max = ', l_msg_no);
- {$ENDIF}
-
- END;
-
- search_block.search_last := NIL;
- search_msg(@search_block);
-
- END;
-
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Something found so first, send the header *)
- (*-----------------------------------------------------------------------*)
-
- send_msg_header(-1);
-
- (*-----------------------------------------------------------------------*)
- (* Now loop around send the message info, searching for next until done *)
- (*-----------------------------------------------------------------------*)
-
- WHILE search_block.search_last <> NIL DO
- BEGIN;
-
- (*-------------------------------------------------------------------*)
- (* Check for more *)
- (*-------------------------------------------------------------------*)
-
- IF command_l = 2 THEN
- BEGIN;
- IF active_tcb^.out_line >= l_msg_no THEN
- BEGIN;
- IF more_prompt THEN
- BEGIN;
- IF save_l <> 0 THEN
- active_tcb^.last_l_time := save_l;
- active_tcb^.out_force := FALSE;
- EXIT;
- END;
- more_clear;
- END;
- END
- ELSE
- BEGIN;
- IF more_check THEN
- BEGIN;
- IF save_l <> 0 THEN
- active_tcb^.last_l_time := save_l;
- EXIT;
- END;
- END;
-
- (*-------------------------------------------------------------------*)
- (* Get the header string *)
- (*-------------------------------------------------------------------*)
-
- cmd_string := header_msg_block(search_block.search_last, -1) + cr;
-
- (*-------------------------------------------------------------------*)
- (* If not a console then just put it out. If it is a console, then *)
- (* send each line seperately *)
- (*-------------------------------------------------------------------*)
-
- IF NOT active_tcb^.tcb_console THEN
- send_tnc_data_str(cmd_string)
- ELSE
- WHILE cmd_string <> '' DO
- BEGIN;
- code := POS(cr, cmd_string);
- send_tnc_data_str(substr(cmd_string, 1, code));
- IF code <> 0 THEN
- cmd_string := substr(cmd_string, code+1, 0)
- ELSE
- cmd_string := '';
- END;
-
- (*-------------------------------------------------------------------*)
- (* If under review or in hold then put reason message *)
- (*-------------------------------------------------------------------*)
-
- IF ((search_block.search_last^.msg_i_mb.msg_flag AND
- (mf_hold OR mf_review) <> 0))
- AND (search_block.search_last^.msg_i_mb.msg_reason <> 0) THEN
- send_message(search_block.search_last^.msg_i_mb.msg_reason);
-
- (*-------------------------------------------------------------------*)
- (* Search for next hit *)
- (*-------------------------------------------------------------------*)
-
- search_msg(@search_block);
-
- END;
-
- active_tcb^.out_force := FALSE;
-
- (*-----------------------------------------------------------------------*)
- (* If this was a command to list since last l command, update the info *)
- (*-----------------------------------------------------------------------*)
-
- IF save_l <> 0 THEN
- active_tcb^.last_l_time := save_l;
-
- END;
-
- END.